/*
Online Java - IDE, Code Editor, Compiler
Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

import java.util.*;

public class Main
{
    //TEST CASES*********************************************************************8
    //static int []nums = new int[]{100,4,200,1,2,6,7,8,9,100,101,102,103};
    //static int []nums = new int[]{100,4};
    //static int []nums = new int[] {1,2,3,4};
   //static int []nums = new int[] {8,1,6,2,9,7,3,100,4,5};
   //static int []nums = new int[] {10,11,12,50,51,52};
    //static int []nums = new int[]{1,1,1,1,1,1};
    //static int []nums = new int[]{100,4,200,1,0,3,2};
    
    //Test cases table (First tests)
    //static int []nums = new int[] {5};   //Issue if OPTION 2:  ArrayIndexOutOfBoundsException
    //static int []nums = new int[] {100,4};
    //static int []nums = new int[] {1,2,3,4};
    //static int []nums = new int[] {100,4,200,1,3,2};
    //static int []nums = new int[] {1,2,2,3};
    //static int []nums = new int[] {10,11,12,50,51,52};
    //static int []nums = new int[] {8,1,6,2,9,7,3,100,4,5};
    //static int []nums = new int[] {0,1,2,3};
    //static int []nums = new int[] {100,4,200,1,0,3,2};  //ISSUE if OPTION 2: it mishandles  {0,1,2,3,4} and {1,2,3,4} as same length
    //static int []nums = new int[] {-3,-2,-1,5,6};
    //static int []nums = new int[] {1,1,1,1};
    //static int []nums = new int[] {};  //Issue if OPTION 2:  ArrayIndexOutOfBoundsException
    //static int []nums = new int[] {1,10,2,20,3,30};
    //static int []nums = new int[] {5,6,7,50,51,52,53,1,2,3,4};
    //static int []nums = new int[] {9,1,4,7,3,2,6,5,8,8,2,1};
    //static int []nums = new int[] {0};
    //static int []nums = new int[] {0,0,0};
    //static int []nums = new int[] {-1,0,1,2};
    //static int []nums = new int[] {-2,-1,0,2,1,10};
    //static int []nums = new int[] {0,2,4,6};
    //static int []nums = new int[] {0,1,1,2,2,3,3,4};
    //static int []nums = new int[] {0,5,6,7,8};
    //static int []nums = new int[] {-5,-4,-3,-2,-1,0};
    //static int []nums = new int[] {0,1,2,50,51,52,53,54,55};
    
    
    //Additional “0 in the middle” torture tests
    //static int []nums = new int[] {2,3,4,0,1};
    //static int []nums = new int[] {-1,0,1,2,3};
    //static int []nums = new int[] {-1,0,1,2,100};
    //static int []nums = new int[] {0,-1,-2,-3};
    
    //Combined test suite
    //static int []nums = new int[] {-2,-1,0,1,2};
    //static int []nums = new int[] {-4,-3,-2,-1,0,1};
    //static int []nums = new int[] {-1,0,1,2,3,50};
    //static int []nums = new int[] {-3,-2,-1,0,1,2,100,101};
    //static int []nums = new int[] {0,0,1,2,3,0,4};
    //static int []nums = new int[] {0,2,0,1,0,3,0,4,0};
    //static int []nums = new int[] {0,1,2,2,3,3,4,0,0};
    //static int []nums = new int[] {0,100,0,101,0,102,0,103};
    //static int []nums = new int[] {0,5,6,7,8};
    //static int []nums = new int[] {2,3,4,0,1};
    //static int []nums = new int[] {0,-1,-2,-3};
    //static int []nums = new int[] {-10,-9,-8,0,1,2,3};
    //static int []nums = new int[] {-5,-4,-3,-2,-1,0};
    //static int []nums = new int[] {0,1,2,50,51,52,53,54,55
    //static int []nums = new int[] {0,1,3,4,5,6,7,8,9};
    //static int []nums = new int[] {1,1,2,2,3,3,4,4};
    //static int []nums = new int[] {5,5,5,4,4,3,3,2,2,1,1};
    //static int []nums = new int[] {7,1,9,2,8,3,10,4};
    //static int []nums = new int[] {1,100,2,200,3,300,4,400};
    //static int []nums = new int[] {0,1,2,3,4,5,6,7,8,9};
    
    //Test cases table (Further tests)
    //static int []nums = new int[] {-2,-1,0,1,2};
    //static int []nums = new int[] {-4,-3,-2,-1,0,1};
    //static int []nums = new int[] {-1,0,1,2,3,50};
    //static int []nums = new int[] {-10,-9,-8,0,1,2,3};
    //static int []nums = new int[] {-3,-2,-1,0,1,2,100,101};
    //static int []nums = new int[] {0,0,1,2,3,0,4};
    //static int []nums = new int[] {0,1,2,2,3,3,4,0,0};
    //static int []nums = new int[] {0,100,0,101,0,102,0,103};
    //static int []nums = new int[] {1,1,2,2,3,3,4,4};
    //static int []nums = new int[] {5,5,5,4,4,3,3,2,2,1,1};
    //static int []nums = new int[] {10,10,10,11,11,12,12,13};
    //static int []nums = new int[] {1,2,3, 10,11,12, 20,21,22};
    //static int []nums = new int[] {50,51,52,53, 1,2,3,4};
    //static int []nums = new int[] {8,9,10, 1,2,3,4,5, 100};
    //static int []nums = new int[] {1,100,2,200,3,300,4,400};
    //static int []nums = new int[] {7,1,9,2,8,3,10,4};
    //static int []nums = new int[] {-8,-7,-6,-5,-4};
    //static int []nums = new int[] {-1,-1,-2,-2,-3,-3};
    //static int []nums = new int[] { 15, 3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 14, 13 };
    //static int []nums = new int[] { 100, 4, 200, 1, 3, 2, 5, 6, 7, 8, 9, 10 };
    //static int []nums = new int[] {2,1};
    //static int []nums = new int[] {2,3,4,5,1};
    //static int []nums = new int[] {-2,-1,0,1,2};
    //static int []nums = new int[] {-6,3,-1,7,-3,2,1,0,-4,-5,5,4,-2,6,8};
    //static int []nums = new int[] {-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,50,51,52};
    //static int []nums = new int[] {-2,-1,0,1,2,2,3,3,4,5,100,101,102,103,104,105};
    //static int []nums = new int[] {0,-1,-2,-3,-4,-5,10,11,12,13,14,15,16,17,100};
    
    //static int []nums = new int[] {30,31,32,33,34,35,36,37,38,39,40,-1,0,1};
    //static int []nums = new int[] {1,2,2,3,4,4,5,6,7,8,9,-1,0,-2,-3};
    //static int []nums = new int[] {0,0,0,-1,-2,-3,-4,1,2,3,4,5,6};
    //static int []nums = new int[] {-9,-8,-7,-6,-5,-4,-3,-2,-1,0,20,21,22,23,24,25,26,27};
    //static int []nums = new int[] {-100,-99,-98,-97,-96,0,1,2,3,4,5,6,7,8,9,10};
    
    //final tough
    //static int []nums = new int[] {0,0,-2,-1,0,1,2,0, 10,11,12,13,14,0, 50,51,52,53,54,0};
    //static int []nums = new int[] {0,-3,-2,-1,0,1,2,0, 20,21,22,23,24,25,0, 100,101,102,103,104,105,0,0};
    //static int []nums = new int[] {0,-2,-1,0,1,2,3,0, 50,51,52,53,54,0, 100,101,102,103,104,0};
    //static int []nums = new int[] {0,0,1,2,3,4,0, -5,-4,-3,-2,-1,0, 10,11,12,13,14,0, 100,101,102,103,104,0};
    //static int []nums = new int[] {0, -4,-3,-2,-1,0,0, 30,31,32,33,34,0, 60,61,62,63,64,0};
    //static int []nums = new int[] {0,0,1,2,3,4,5,0, 20,21,22,23,24,25,0, -10,-9,-8,-7,-6,-5,0,0};
    //static int []nums = new int[] {0,100,101,0,102,103,104,0, -1,0,1,2,3,0, 200,201,202,203,204,0};
    //static int []nums = new int[] {0,1,2,3,4,0,0, -2,-1,0,1,2,0, 10,11,12,13,14,0};
    //static int []nums = new int[] {0, -6,-5,-4,-3,-2,-1,0, 0,1,2,3,4,5,0, 50,51,52,53,54,55,0, 100,101,102,103,104,105,0};
    
    //Test case literal	Negative 		Positive or  negative  to 0
    //static int []nums = new int[] {-9,-8,-7,-6,-5,-4,-3,-2,-1,0, 20,21,22,23,24,25,26,27};
    //static int []nums = new int[] {-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0, 30,31,32,33,34,35,36,37};
    //static int []nums = new int[] {-7,-6,-5,-4,-3,-2,-1,0, 100,101,102,103,104,105,106,107};
    //static int []nums = new int[] {-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0, 1,2,3,4,5,6,7,8,9};
    //static int []nums = new int[] {-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0, 40,41,42,43,44,45};
    //static int []nums = new int[] {-6,-5,-4,-3,-2,-1,0, 10,11,12,13,14,15, 200,201};
    //static int []nums = new int[] {-8,-7,-6,-5,-4,-3,-2,-1,0, 50,51,52,53,54,55,56,57,58};
    //static int []nums = new int[] {-5,-4,-3,-2,-1,0, 1,2,3,4,5, 100,101,102,103,104};
    //static int []nums = new int[] {-9,-8,-7,-6,-5,-4,-3,-2,-1,0, 70,71,72,73,74,75,76,77, 0,0};
    //static int []nums = new int[] {0, -11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1, 90,91,92,93,94,95,96};
    
    //ULTIMATE test
    static int []nums = new int[] { 0,0, 50,51,52,53,54,55, -12,-11,-10,-9,-8,-7, 10,11,12,13,14,15, 100,101,102,103,104,105, -2,-1,0,1,2,3, 0,0,0, 200,300,400,-100,-50,999, 7,8,17,18,70,72,90,92, 12,52,101,-10,55,105, 0,0, 250,260,-200,33,35, 0,0,0 };
    
    
    //Using above three torture test cases to see if both options for the if loop are ok
    //it relates to section where it decides on storing sequence if it equal to existing in storeMaxConsecutiveSequences
    //static int []nums = new int[] {0,0,1,2,3,0,4};
    //static int []nums = new int[] {0,2,0,1,0,3,0,4,0};
    //static int []nums = new int[] {2,3,4,0,1};
    
    
    //Since we can not be sure how long each sequence will be, we have to use the worst case scenario to determine
    //that each number might have no consecutive chains
    
    //and also since all elements in nums can be consecutive, we have to assume that
    //a single consecutive chain can be populated  stored in any index between (0-nums.length-`1)`  Store[0][nums.length]
    //it has no knowledge about duplicate values such as
    //static int []nums = new int[] {1,2,2,3},  so its one size fits all
    static int[][] Store = new int[nums.length][nums.length];
    
    //need to phase out since String
    //static String [] temp = new String[nums.length];
    //this now needs to be a 3D array to hold  static int[][] Store
    //need to be careful in that there is  a single 2D array  at each location in the 3D array
    static int [][][] storeMaxConsecutiveSequences = new int [nums.length][1][nums.length];
    
    static int differenceCheck;
    static int count=0;
    static int firstNum;
    static int nextNum;
    
    static int countSequencesStored;
    
    public static boolean nextnumbercheck(int firstNum)
    {
        for (int i=0; i<nums.length; i++)
        {
            if (nextNum==nums[i])
            {
                count++;
                Store[firstNum][count]=nextNum;
                return true;
            }
        }
        count=0;
        return false;
    } //end of method
    
    public static void main(String[] args) 
    {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        boolean nextnumberconsecutive=false;
        
        for (int i=0; i< nums.length; i++)
        {
            Store[i][count]=nums[i];
            System.out.println("\nThis is the number being checked: " + nums[i]);
            differenceCheck=1;
            
            for (int j=0; j<nums.length; j++)
            {
                if (j==i) 
                {
                    j++;
                }
                if (j!=nums.length)
                {
                    if (nums[j]==nums[i]+differenceCheck)
                    {
                        count++;  
                        do
                        {
                            System.out.println("Next consecutive number has appeared: " + (nums[i]+differenceCheck));
                            Store[i][count]= nums[i]+differenceCheck;
                            differenceCheck++;
                            nextNum = nums[i]+differenceCheck;  //next consecutive number expected....
                            nextnumberconsecutive = nextnumbercheck(i);
                        }while(nextnumberconsecutive);
                        
                    }
                }
            }  //end of inner for loop
        }  //end of for loop going through all nums
   
        System.out.println("\n\nLength of store: " + Store.length);
        System.out.println("********These are all entries*********");
        
        for (int max[]: Store)   
        {
            System.out.println(Arrays.toString(max));
        }
        
        StringJoiner sj = new StringJoiner(",");
        int currentMaximumConsectiveNumbers=0;
        String numtoString;
        
        //completed inline with test case 3
        //boolean conditionOnce=false;
        int currentI=0;
        int j=0;
        int zeroFoundLocation=0;
        boolean zeroFound=false;
        int posZero=0;
        
        int indexZeroElementInArray=0;
        
        //now introduced as part of transitioning into integer
        int index;
        
        //Completed inline with test case 3
        //int oldConsecutiveNumbers=0;
        String backupStringJoiner;
        int countIndexLocationsNoZero=0;
        
        //introduced inline with moving away from Strings
        int [] currentConsecutiveElements = new int[nums.length];
        //int [] backupConsecutiveElements = new int[nums.length];
        
        int captureIndex=0;
        
        int backupPosZero=0;
        
        boolean hasExecuteOnce=false;
        boolean hasZeroFound=false;
        
        
        for (int i=0; i<Store.length; i++)
        {
            System.out.println("\n******NEW NUMBER*****:  " + Arrays.toString(Store[i]));
            System.out.println("This is current highest consecutive Numbers in sequence stored: " + currentMaximumConsectiveNumbers);
            System.out.println("TRACK poszero: " + posZero);
            
            hasExecuteOnce=false;
            
            backupPosZero=posZero;
            
            captureIndex=0;
            //no longer required, moving away Strings
            //sj=new StringJoiner(",");
            countIndexLocationsNoZero=0;
            index=0;
            
            //we now have to also reset this 
            //posZero=0;
            
            for (j=0; j<Store[0].length; j++)
            {
                
                //need to consider phasing out Strings
                //it refers to single index location
                //numtoString=Integer.toString(Store[i][j]);
                
                int elementInArray = Store[i][j];
                
                
                zeroFound=false;
                
                //no longer required
                //conditionOnce=true;
                
                //this requires more effort to phase out
                //backupStringJoiner = sj.toString();
                //sj.add(numtoString);
                
                //backupConsecutiveElements = currentConsecutiveElements;
                currentConsecutiveElements[index] = elementInArray;
                
                index++;
                
                //System.out.println(Store[i][j]);
                //System.out.println(j);
                
                //System.out.println("----------------------------VALUE IN J: " + j);
                
                
                if (elementInArray==0)
                {
                    System.out.println("Zero found at index: " + j  + " => " + Store[i][j]);
                    
                    indexZeroElementInArray = j;
                    
                    
                    //aiming to phase out Strings
                    //sj=new StringJoiner(",");
                    //sj.add(backupStringJoiner);
                    //currentConsecutiveElements=backupConsecutiveElements;
                    
                     captureIndex = j;
                     hasZeroFound=true;
                        
                    if (captureIndex>=posZero)
                    {
                        posZero=captureIndex;
                    }
                        
                    //no longer need this structure
                    //to support Test case 4
                    //if (j>zeroFoundLocation)
                    //{
                    zeroFoundLocation=j;
                    //}
                    zeroFound=true;
                    
                    if (j+1<Store[i].length-1)
                    {
                        if (j!=0 && nums.length!=1 && Store[i][j+1]==0)
                        {
                            System.out.println("MAX OUT!!!!!!!!!!!!!!!!!!!");
                            j=nums.length;
                            //break;
                        }
                    }
                    
                    //I performed this change inline with Test case 3
                    //Logic. Most parts have now been scattered across different areas
                    /*
                    if (conditionOnce)
                    {
                        System.out.println("ENTER HERE");
                        oldConsecutiveNumbers = currentMaximumConsectiveNumbers;
                        currentMaximumConsectiveNumbers=zeroFoundLocation;
                        conditionOnce=false;
                    }
                    */
                    
                    
                    //For cases such as static int []nums = new int[] {2,3,4,0,1};
                    //it would store 2,3,4  as 2,3,4,0,0
                    //it would progress right to the end since we know that a 0 can be part of descending
                    //sequence anywhere in the chain
                    //So currentMaximumConsectiveNumbers would be 4 at completion...
                    //And currentMaximumConsectiveNumbers is actually 3
                    
                    //so we need to keep track of in the code if it finds two consecutive zeros
                    
                    System.out.println(j-1);
                    
                    if (j-1>=0)
                    {
                        if (Store[i][j-1]==0 && hasZeroFound && j==(Store[i].length-1))
                        {
                            System.out.println("REACH HERE!!!!!!!!!!!!!!");
                            
                            if (!hasExecuteOnce)
                            {
                                System.out.println("ADJUST VALUE-------------------------------------------");
                                captureIndex=j-1;
                                posZero=posZero-1;
                                zeroFound=false;
                                hasExecuteOnce=true;
                            }
                        }
                    }
                }
                else
                {
                    //System.out.println("111: " + posZero);
                    System.out.println("222No zero found (index: " + j+") " + " => " + Store[i][j]);
                    
                    //if (j>=posZero && countIndexLocationsNoZero>0)
                    //{
                        //System.out.println("WHEN----------------");
                    if (j>=posZero)
                    {
                        posZero=j;
                        System.out.println("CONFIGURE: " + posZero);
                    }
                    //}
                    //else
                    //{
                        //posZero=currentMaximumConsectiveNumbers;
                    //}
                    //zeroFoundLocation=;
                    countIndexLocationsNoZero++;
                    zeroFound=false;
                }
                
                //Changes inline with test case 3
                //I also no longer dealt with oldConsecutiveNumbers (phased out), so it was currentMaximumConsectiveNumbers which
                //now fitted better across the board
                //I have to consider this valid if there is a zerofound=true or if it has traversed entire array and
                //acknowledged no zeros found
                
                
                System.out.println("1TRACK poszero1: " + posZero);
                System.out.println("1zero found: " + zeroFound);
                System.out.println("1value j: " +  j);
                System.out.println("1current max: " + currentMaximumConsectiveNumbers);
                System.out.println("1zerofoundlocation: " + zeroFoundLocation);
                System.out.println(nums.length);
                System.out.println("1countIndexLocationsNoZero: " + countIndexLocationsNoZero);
                //|| (j>=posZero && (j==nums.length-1)
                System.out.println("capture index: " + captureIndex);
                System.out.println("count sequence: " + countSequencesStored);
                System.out.println("nums-1: " + (nums.length-1));
                
                
                if (posZero>backupPosZero && posZero>captureIndex && (j==nums.length-1 ||j==nums.length))
                {
                    System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
                    posZero=captureIndex;
                }
                
                
                //capture index <poszero && countSequencesStored==0
                
                //or  countsequence>1 && captureIndex>=poszero
                
                //if ((captureIndex<posZero && countSequencesStored==0 && j==nums.length-1 || j==nums.length) || (countSequencesStored>0 && captureIndex>=posZero && j==nums.length-1 ||j==nums.length))
                System.out.println(j);
                
                int lastElementIndex=0;
                
                if (j>nums.length-1)
                {
                    lastElementIndex=j-1;
                }
                else if (j==nums.length-1)
                {
                    lastElementIndex=j;
                }
                
                //if (posZero>currentMaximumConsectiveNumbers)
                System.out.println("INDEX: " + lastElementIndex);
                System.out.println("last: " + Store[i][lastElementIndex]);
                System.out.println("ssss: " + Store[i][lastElementIndex]);
                
                //we surely need exception handling at this point for test case 18
                //since it is performing execution up tostatic int []nums = new int[] {-1,0,*1,2}
                //and then it decides to enter this loop
                
                boolean hasMoreConsecutive=false;
                
                try
                {
                    if (Store[i][j+1]!=0)
                    {
                        hasMoreConsecutive=true;
                    }
                    System.out.println("MORE LEFT--------------------------------------------");
                }
                catch (ArrayIndexOutOfBoundsException s)
                {
                    System.out.println("ENTERING CATCH********************************************************");
                    
                    //}
                
                    //if (!hasMoreConsecutive)
                    //{
                    //if ((captureIndex>currentMaximumConsectiveNumbers || nums.length==1  || (captureIndex==posZero 
                    //&& countSequencesStored==0 && Store[i][lastElementIndex]==0 && Store[i][nums.length-1]==0))  
                    //|| (countSequencesStored==0 && posZero==nums.length-2  /*Store[i].length-2*/))
                
                    //I have not had to simplify the above loop to this, since when I completed the try and catch statements
                    //it no longer decided to accept the above statements at all. I found this particular strange since test case
                    //static int []nums = new int[] {1,2,3,4} had no issues in Main - passes Test case 9.java
                
                
                    //If I keep this loop active as oppose to the above one it treats
                    //static int []nums = new int[] {100,4,200,1,0,3,2};  //it mishandles  {0,1,2,3,4,0,0} and {1,2,3,4,0,0} as same length  
            
            
                    System.out.println("BEFORE NEWLY¬¬¬¬¬¬¬¬¬¬¬¬¬-----------------------------------------------");
                    
                    if (countIndexLocationsNoZero>currentMaximumConsectiveNumbers || posZero>currentMaximumConsectiveNumbers)
                    /*||countIndexLocationsNoZero>currentMaximumConsectiveNumbers && j>=nums.length-*/
                    /*||Store[i][j+1]==0 && captureIndex!=0*/
                
                    //this would be if 0 at front
                    //if (captureIndex==nums.length-1  || countIndexLocationsNoZero==nums.length-1 && countIndexLocationsNoZero!=posZero && posZero==nums.length-1  
                    //|| (captureIndex==0 && posZero==(nums.length-1) && !zeroFound && (Store[i][j]==0 || Store[i][0]==0)))
                    {
                        if (j<nums.length-1)
                        {
                            if (Store[i][j+1]==0)
                            {
                                System.out.println("1Zero found at index: " + (j+1)  + " => " + Store[i][nums.length-1]);
                                countIndexLocationsNoZero=j+1;
                                
                                j++;
                            }
                            else
                            {
                                System.out.println("No zero found (index: " + (j+1)+") " + " => " + Store[i][j+1]);
                                countIndexLocationsNoZero++;
                                j++;
                            }
                        }
        
                        // ((zeroFoundLocation>=currentMaximumConsectiveNumbers && zeroFound) 
                        //|| ((j==nums.length-1) && !zeroFound && countIndexLocationsNoZero>=posZero))
                        //{
                        //if ((Store[i][j-1])==0 && (j==nums.length) && (zeroFoundLocation!=nums.length-1) /*|| (Store[i][0])==0*/)
                        //{
                    
                        //This has now been changed to currentMaximumConsectiveNumbers
                        //System.out.println("This is current highest streak of consecutiveNumbers: " + oldConsecutiveNumbers);
                        System.out.println("This is current highest streak of consecutiveNumbers: " + currentMaximumConsectiveNumbers);
                    
                        //oldConsecutiveNumbers=zeroFoundLocation;
                        //if (j==nums.length-1)
                        //{
                    
                        //For cases such as static int []nums = new int[] {2,3,4,0,1};
                        //it would store 2,3,4  as 2,3,4,0,0
                        //it would progress right to the end since we know that a 0 can be part of descending
                        //sequence anywhere in the chain
                        //So currentMaximumConsectiveNumbers would be 4 at completion...
                        //And currentMaximumConsectiveNumbers is actually 3
                    
                        //so we need to keep track of in the code if it finds two consecutive zeros....
                    
                        currentMaximumConsectiveNumbers=posZero;
                    
                        System.out.println("CHECK1: " + currentMaximumConsectiveNumbers);
                        //}
                        //Fix for test case 1
                    
                        if (j==0 && Store[i].length==0)
                        {
                             currentMaximumConsectiveNumbers=1;
                        }
        
                        System.out.println("CHECK: " + currentMaximumConsectiveNumbers);
                        //if (j==nums.length-1 && Store[i][0]==0)
                        //{
                        //   currentMaximumConsectiveNumbers++;
                        //}
        
                        if (captureIndex>currentMaximumConsectiveNumbers)
                        {
                            System.out.println("CHECK7");
                            currentMaximumConsectiveNumbers=captureIndex;
                        }
                        System.out.println("CHECK3: " + currentMaximumConsectiveNumbers);
        
                        if (countIndexLocationsNoZero>currentMaximumConsectiveNumbers)
                        {
                            currentMaximumConsectiveNumbers=countIndexLocationsNoZero;
                            System.out.println("CHECK4: " + currentMaximumConsectiveNumbers);
                        }
        
                        //This is now a fix for test case  {0,1,2,3}
                        if (Store[i][0]==0 && countIndexLocationsNoZero==Store[i].length-1)
                        {
                            currentMaximumConsectiveNumbers++;
                            System.out.println("CHECK5: " + currentMaximumConsectiveNumbers);
                        }
        
                        //I did not want to interrogate the difference like this...
                        //But it becomes impossible otherwise since the 0 might be part of descending sequence and appearing..
                        //We will never know otherwise if it is part of the sequence or the default value in storage...
                        //Having 0 in front is more clear cut as above
                        //useful for tests such as static int []nums = new int[] {0,5,6,7,8};
                        //where one of the sequences is  5,6,7,8  and it will be populated as  5,6,7,8,0
                        //I have not kept tracking of the frequency elements populated in Store for each consecutive sequence
                        //So best of my knowledge there is no other known technique
        
                        boolean hasAdjust=false;
        
                        //System.out.println(j-1);
                        //System.out.println(Store[i][j-1]);
        
                        //this outer loop is used to protect
                        //static int []nums = new int[] {0,1,1,2,2,3,3,4};
        
                        if (j!=nums.length)
                        {
                            if (Store[i][j]==0 && countIndexLocationsNoZero==Store[i].length-1 
                            && (Store[i][j-1]+1)==Store[i][j])
                            {
                                currentMaximumConsectiveNumbers++;
                                System.out.println("CHECK6: " + currentMaximumConsectiveNumbers);
                                //hasAdjust=true;
                            }
                        }
        
                        if (j==currentMaximumConsectiveNumbers && Store[i][j]!=0)
                        {
                            currentMaximumConsectiveNumbers++;
                        }
        
                        System.out.println("************************************");
        
                        System.out.println("store length: " + Store[i].length);
                        System.out.println("j: " + j);
                        System.out.println("nums length: " + nums.length);
                        System.out.println(lastElementIndex);
        
        
                        //This is only way now to determine for instance test case
                        //static int []nums = new int[] {4,5,6,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,25}
                        //as to whether end 0 is due to legitimate 0 in Store[i]
                        //This is first time we have to examine nums array
                        //[[-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 0]]
          
                        //But we also need to be aware of test case
                        //static int []nums = new int[] {0,0,1,2,3,4,0, -5,-4,-3,-2,-1,0, 10,11,12,13,14,0, 100,101,102,103,104,0};
                        //which presents continuation beyond 0
                        // [[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
          
  
                        for (int k: nums)
                        {
                            //if there is k in original data and first element in Store[i] is not zero
                            //This will determine it is consecutive from high negative to 0
                            //We know elementInArray is zero
                            //And we also captured indexZeroElementInArray at that moment in time when it found a 0
                            //where it considered to terminate the consecutive sequence
                            //if (k==0 && Store[i][0]!=0 && ((Store[i][indexZeroElementInArray]+1)==elementInArray))
                            if (k==0 && Store[i][0]!=0 && ((Store[i][posZero-1]+1)==elementInArray))
			    {
                                System.out.println("consecutive in negative direction");
                                currentMaximumConsectiveNumbers=currentMaximumConsectiveNumbers+1;
                
                                for (int g=0; g<indexZeroElementInArray;g++)
                                {
                                    if (Store[i][g]==0)
                                    {
                                        System.out.println("Earlier 0 at index:  " + g);
                                        System.out.println("Sequence negative => positive");
                                        currentMaximumConsectiveNumbers=currentMaximumConsectiveNumbers-1;
                                        break;
                                    }
                                }
                                break;
                            }
                        }
        
                        if (Store[i].length>(j+1)+1)
                        {
                            System.out.println("0 in original dataset");
                            currentMaximumConsectiveNumbers=currentMaximumConsectiveNumbers+1;
                        }
                        
                        hasAdjust=false;
                        
                        if(Store[i].length==1)
                        {
                            currentMaximumConsectiveNumbers=1;
                        }
                    
                        System.out.println("This is newly identified streak of consecutive Numbers: " + currentMaximumConsectiveNumbers);
                    
                        if (countIndexLocationsNoZero==(nums.length-1))
                        {
                            posZero=nums.length-1;   
                        }
                        else
                        {
                            posZero=countIndexLocationsNoZero;
                        }
                    
                        //Need to consider phasing out String for a numerical challenge
                        //curretemp = new String[nums.length];
                        //temp[0]=sj.toString();
                        //currentConsecutiveElements = new int[nums.length];
                    
                        //no longer valid
                        //System.out.println("Highest consecutive number sequence so far: " + temp[0]);
                    
                        //We need to also clear the exissting array for storeMaxConsecutiveSequences
                        storeMaxConsecutiveSequences = new int [nums.length][1][nums.length];
                    
                        //We know that Store is  2d array [][]
                        //so now, we need to store this in a 3D array in repository...
                        //we know that since the first row of storage is overwritten, it is ok to process as such
                        storeMaxConsecutiveSequences[0][0]= Store[i];
                    
                        //We need to keep a counter here of the number of times that it has stored a consecutive sequence
                        countSequencesStored++;
                    
                        /*
                        int elem=0;
                        for (int[] row: Store)
                        {
                            for (int element: row)
                            {
                                System.out.println("element: " + element);
                                storeMaxConsecutiveSequences[0][1][elem] = element;
                            }
                        
                        elem++;
                        }
                        */
                    
                        //elem=0;
                    
                        //storeMaxConsecutiveSequences[0] = new int[][][] {Store[i][]}; 
                        System.out.println("Highest consecutive number sequence so far: " + Arrays.toString(Store[i]));
                        break;
                    }
                }
                
                System.out.println("TRACK poszero1: " + posZero);
                System.out.println("zero found: " + zeroFound);
                System.out.println("value j: " +  j);
                System.out.println("current max: " + currentMaximumConsectiveNumbers);
                System.out.println("countIndexLocationsNoZero: " + countIndexLocationsNoZero);
                System.out.println("hasMoreConsecutive:  " + hasMoreConsecutive);
                //|| (j>=posZero && (j==nums.length-1)
                
                if (zeroFound && posZero==0)
                {
                    j=0;
                }
                
                /*
                if (j>posZero)
                {
                    System.out.println("fff: " + Store[i][posZero+1]);
                    
                if (Store[i][posZero+1]==0)
                {
                    posZero=posZero+1;
                    
                }
                }
                */
                
                if (posZero>backupPosZero && posZero>captureIndex && (j==nums.length-1 ||j==nums.length))
                {
                    System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
                    posZero=captureIndex;
                }
                //System.out.println(zeroFound);
                //We no longer reference zero found. This is perhaps seems like most glaring mistaken in my old code.
                
                if (!hasMoreConsecutive)
                {
                    //Since I know this tackles extreme cases such as
                    //But it fails to give multiple same outputss of {0,1,2,3,4}
                    //static int []nums = new int[] {0,0,1,2,3,0,4};
                    //static int []nums = new int[] {0,2,0,1,0,3,0,4,0};
                    //if it meets this condition, I need to prevent is from passing through the inner
                
                    if ((countIndexLocationsNoZero==currentMaximumConsectiveNumbers)
                    &&countIndexLocationsNoZero+1==currentMaximumConsectiveNumbers  && Store[i][0]==0)
                    {
                        System.out.println("The following: " + Arrays.toString(Store[i]) + 
                        "      has been stored. \nIt is also equal to current maximum sequence of consecutive numbers: " + currentMaximumConsectiveNumbers);
                        storeMaxConsecutiveSequences[countSequencesStored][0]= Store[i];
                    
                        //We also know that there will be another entry in storeMaxConsecutiveSequences since this area of code
                        //defines that the current sequence also is same length. 
                        countSequencesStored++;
                    
                        //phased out in relation to eliminating Strings
                        //temp[i]=sj.toString();
                        break;
                    }
                //{
                    else
                    {
                        System.out.println("INSIDE HAS MORE..............................................................");
                        System.out.println(j>=posZero);
                        System.out.println(posZero!=0);
                        System.out.println(zeroFound);
                        System.out.println(countIndexLocationsNoZero>=posZero);
                        //System.out.println(Store[i][j-1]!=0);
                        System.out.println(j>=nums.length);
                        System.out.println("\n");
                        System.out.println(countIndexLocationsNoZero);
                        System.out.println(currentMaximumConsectiveNumbers);
                        System.out.println(j==nums.length);
                        System.out.println("\n");
                        System.out.println(countIndexLocationsNoZero+1);
                        System.out.println(Store[i][0]==0);
                    
                        if ((j>=posZero &&posZero!=0 && zeroFound && countIndexLocationsNoZero>=posZero && Store[i][j-1]!=0 && j>=nums.length)
                        || ((countIndexLocationsNoZero==currentMaximumConsectiveNumbers && (j==nums.length)
                        ||countIndexLocationsNoZero+1==currentMaximumConsectiveNumbers  && Store[i][0]==0)))
                    
                    
                        //I have included this for test case  static int []nums = new int[] {0,0,1,2,3,0,4};
                        //since it is failing to  record  {0,1,2,3,4}  for all three existence of {0,1,2,3,4,0,0}
                        //This is part of the extra torture tests
                 
                 
                        //If i use this loop BELOW (instead of the above if loop), test case below passes
                        //static int []nums = new int[] {2,3,4,0,1};
                        //AND SO do all other test cases
                        //But it fails to give multiple same outputss of {0,1,2,3,4}
                        //static int []nums = new int[] {0,0,1,2,3,0,4};
                        //static int []nums = new int[] {0,2,0,1,0,3,0,4,0};
                        //We know the fix was including this line in above if statement
                        //||countIndexLocationsNoZero+1==currentMaximumConsectiveNumbers  && Store[i][0]==0)
                        //So I can consider including the line in the below if statement also and discarding if statement above
                        //OR I can include:
                        //countIndexLocationsNoZero==currentMaximumConsectiveNumbers
                        //in the if statement above
                
                        //if ((countIndexLocationsNoZero==currentMaximumConsectiveNumbers)
                
                //    ||countIndexLocationsNoZero+1==currentMaximumConsectiveNumbers  && Store[i][0]==0)
                
                        {
                            System.out.println("DSDSADSADAS");
                            //if (j!=nums.length-1 && Store[i][j+1]==0)
                            //{
                            System.out.println("posZero: " + posZero);
                    
                            //We need to keep a counter here of the number of times that it has stored a consecutive sequence
                            //This is because we have defined the 3D array as
                            //static int [][][] storeMaxConsecutiveSequences = new int [nums.length][1][nums.length];
                            //So, if it has 1 row of populated information (this is not hypothetically possible if it reaches this loop)
                            //It will show content such as
                            //[[1, 2, 3, 4]]
                            //[[0, 0, 0, 0]]
                            //[[0, 0, 0, 0]]
                            //[[0, 0, 0, 0]]
                    
                            //phased out in relation to eliminating Strings
                            //System.out.println("The following: " + sj.toString() + "      has been stored. \nIt is also equal to current maximum sequence of consecutive numbers: " + currentMaximumConsectiveNumbers);
                    
                            System.out.println("The following: " + Arrays.toString(Store[i]) 
                            + "      has been stored. \nIt is also equal to current maximum sequence of consecutive numbers: " + currentMaximumConsectiveNumbers);
                            storeMaxConsecutiveSequences[countSequencesStored][0]= Store[i];
                    
                            //We also know that there will be another entry in storeMaxConsecutiveSequences since this area of code
                            //defines that the current sequence also is same length. 
                            countSequencesStored++;
                    
                    
                            //phased out in relation to eliminating Strings
                            //temp[i]=sj.toString();
                            break;
                        //}
                        }
                    }
                }
                hasMoreConsecutive=false;
            }//end of for
        }//end of for
        
        //We know this output onto the store could only occur if only number that existed in
        //Store[i] was 0s... The number of entries storeMaxConsecutiveSequences[0].length would 
        //give exact information on number 0s... But this becomes irrelevant..
        //Since they are all 0s, the longest streak can only be 1...
        
        
        if (Store.length==0)
        {
            System.out.println("No data provided");
        }
        
        else
        {
            if(Store[0].length>1)
            {
                if (storeMaxConsecutiveSequences[0][0][0]==0 && storeMaxConsecutiveSequences[0][0][1]==0)
                {
                    System.out.println("All values in initial array are 0");
                    currentMaximumConsectiveNumbers=1;
                }
            }
            else
            {
                if (currentMaximumConsectiveNumbers==0)
                {
                    System.out.println("Single value in initial array is 0");
                    currentMaximumConsectiveNumbers=1;
                }
            }
        }
        
        System.out.println("\n\n****************************");
        System.out.println("Longest consecutive sequence: " + currentMaximumConsectiveNumbers);
        System.out.println("****************************");
         
        //This now requires modification inline with using Integers
        /*
        for (String s: temp)
        {
             if (s!=null)
             {
                 System.out.println(s);
             }
        }
        */
        int counter=0;
        System.out.println("sss: " + countSequencesStored);
        
        //I know from past experiences, in order to display the 
        for (int[][] sequences : storeMaxConsecutiveSequences)
        {
            if (counter==countSequencesStored)
            {
                //break;
            }
            System.out.println(Arrays.deepToString(sequences));
            
            counter++;
        }
        
    }//end of main
}//end of class

